Implement gtk_statusbar_get_message_area and "message_area" child
authorChristian Dywan <christian@twotoasts.de>
Thu, 12 Nov 2009 17:57:37 +0000 (18:57 +0100)
committerChristian Dywan <christian@twotoasts.de>
Thu, 12 Nov 2009 17:57:37 +0000 (18:57 +0100)
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=594535
gtk/gtk.symbols
gtk/gtkstatusbar.c
gtk/gtkstatusbar.h

index 1582eaf48bdcd4a7978dc85847e685f44b4183b9..ba109d9ec8830fc72622bf1bacbeeaf6de7cb6a1 100644 (file)
@@ -3841,6 +3841,7 @@ gtk_spinner_stop
 #if IN_FILE(__GTK_STATUSBAR_C__)
 gtk_statusbar_get_context_id
 gtk_statusbar_get_has_resize_grip
+gtk_statusbar_get_message_area
 gtk_statusbar_get_type G_GNUC_CONST
 gtk_statusbar_new
 gtk_statusbar_pop
index 0a494c912a01fb07ac14f72b75987c8b7d6ea2d4..eda9caae0d9158595b371ce5756487503ee4381f 100644 (file)
@@ -33,6 +33,7 @@
 #include "gtkwindow.h"
 #include "gtkprivate.h"
 #include "gtkintl.h"
+#include "gtkbuildable.h"
 #include "gtkalias.h"
 
 typedef struct _GtkStatusbarMsg GtkStatusbarMsg;
@@ -57,6 +58,10 @@ enum
   PROP_HAS_RESIZE_GRIP
 };
 
+static void     gtk_statusbar_buildable_interface_init    (GtkBuildableIface *iface);
+static GObject *gtk_statusbar_buildable_get_internal_child (GtkBuildable *buildable,
+                                                            GtkBuilder   *builder,
+                                                            const gchar  *childname);
 static void     gtk_statusbar_destroy           (GtkObject         *object);
 static void     gtk_statusbar_update            (GtkStatusbar      *statusbar,
                                                 guint              context_id,
@@ -96,7 +101,9 @@ static void     label_selectable_changed        (GtkWidget         *label,
 
 static guint              statusbar_signals[SIGNAL_LAST] = { 0 };
 
-G_DEFINE_TYPE (GtkStatusbar, gtk_statusbar, GTK_TYPE_HBOX)
+G_DEFINE_TYPE_WITH_CODE (GtkStatusbar, gtk_statusbar, GTK_TYPE_HBOX,
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
+                                                gtk_statusbar_buildable_interface_init));
 
 static void
 gtk_statusbar_class_init (GtkStatusbarClass *class)
@@ -194,6 +201,7 @@ static void
 gtk_statusbar_init (GtkStatusbar *statusbar)
 {
   GtkBox *box;
+  GtkWidget *message_area;
   GtkShadowType shadow_type;
   
   box = GTK_BOX (statusbar);
@@ -212,13 +220,17 @@ gtk_statusbar_init (GtkStatusbar *statusbar)
   gtk_box_pack_start (box, statusbar->frame, TRUE, TRUE, 0);
   gtk_widget_show (statusbar->frame);
 
+  message_area = gtk_hbox_new (FALSE, 4);
+  gtk_container_add (GTK_CONTAINER (statusbar->frame), message_area);
+  gtk_widget_show (message_area);
+
   statusbar->label = gtk_label_new ("");
   gtk_label_set_single_line_mode (GTK_LABEL (statusbar->label), TRUE);
   gtk_misc_set_alignment (GTK_MISC (statusbar->label), 0.0, 0.5);
   g_signal_connect (statusbar->label, "notify::selectable",
                    G_CALLBACK (label_selectable_changed), statusbar);
   gtk_label_set_ellipsize (GTK_LABEL (statusbar->label), PANGO_ELLIPSIZE_END);
-  gtk_container_add (GTK_CONTAINER (statusbar->frame), statusbar->label);
+  gtk_container_add (GTK_CONTAINER (message_area), statusbar->label);
   gtk_widget_show (statusbar->label);
 
   statusbar->seq_context_id = 1;
@@ -227,6 +239,28 @@ gtk_statusbar_init (GtkStatusbar *statusbar)
   statusbar->keys = NULL;
 }
 
+static GtkBuildableIface *parent_buildable_iface;
+
+static void
+gtk_statusbar_buildable_interface_init (GtkBuildableIface *iface)
+{
+  parent_buildable_iface = g_type_interface_peek_parent (iface);
+  iface->get_internal_child = gtk_statusbar_buildable_get_internal_child;
+}
+
+static GObject *
+gtk_statusbar_buildable_get_internal_child (GtkBuildable *buildable,
+                                            GtkBuilder   *builder,
+                                            const gchar  *childname)
+{
+    if (strcmp (childname, "message_area") == 0)
+      return G_OBJECT (gtk_bin_get_child (GTK_BIN (GTK_STATUSBAR (buildable)->frame)));
+
+    return parent_buildable_iface->get_internal_child (buildable,
+                                                       builder,
+                                                       childname);
+}
+
 /**
  * gtk_statusbar_new:
  *
@@ -482,6 +516,24 @@ gtk_statusbar_get_has_resize_grip (GtkStatusbar *statusbar)
   return statusbar->has_resize_grip;
 }
 
+/**
+ * gtk_statusbar_get_message_area:
+ * @statusbar: a #GtkStatusBar
+ *
+ * Retrieves the box containing the label widget.
+ *
+ * Returns: a #GtkBox
+ *
+ * Since: 2.20
+ */
+GtkWidget*
+gtk_statusbar_get_message_area (GtkStatusbar *statusbar)
+{
+  g_return_val_if_fail (GTK_IS_STATUSBAR (statusbar), NULL);
+
+  return gtk_bin_get_child (GTK_BIN (statusbar->frame));
+}
+
 static void
 gtk_statusbar_destroy (GtkObject *object)
 {
index 3ca102b6c819ba5b6b60f453f7909c86d6c38be8..ff0597655c2ddb761b7bef517d888b78af89d6bc 100644 (file)
@@ -107,6 +107,8 @@ void     gtk_statusbar_set_has_resize_grip (GtkStatusbar *statusbar,
                                            gboolean      setting);
 gboolean gtk_statusbar_get_has_resize_grip (GtkStatusbar *statusbar);
 
+GtkWidget* gtk_statusbar_get_message_area  (GtkStatusbar *statusbar);
+
 G_END_DECLS
 
 #endif /* __GTK_STATUSBAR_H__ */